﻿<Window 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
	xmlns:HelpClasses="clr-namespace:HelpClasses;assembly=HelpClasses"
	xmlns:my="clr-namespace:EcoProIT.UserControles;assembly=EcoProIT.UserControles"
	xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
	xmlns:Controls="clr-namespace:FeserWard.Controls;assembly=Intellibox"
    xmlns:adobeImport="clr-namespace:EcoProIT.UserControles.AdobeImport;assembly=EcoProIT.UserControles"
    xmlns:chart="clr-namespace:EcoProIT.Chart;assembly=EcoProIT.Chart"
    xmlns:chart1="clr-namespace:EcoProIT.Chart.Chart;assembly=EcoProIT.Chart"
    xmlns:axis="clr-namespace:EcoProIT.Chart.Axis;assembly=EcoProIT.Chart"
    xmlns:series="clr-namespace:EcoProIT.Chart.Series;assembly=EcoProIT.Chart"
    mc:Ignorable="d"
	x:Class="EcoProIT.UI.MainWindow"
	Title="EcoProIT Tool" Height="900" WindowState="Maximized" Width="1529.95" Icon="Resources/Icon.ico">
	<Window.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="Template.xaml" />
			</ResourceDictionary.MergedDictionaries>
            <HelpClasses:BooleanInvertToVisibilityConverter x:Key="BooleanInvertToVisibilityConverter"/>
            <HelpClasses:BoolInverter x:Key="BoolInverter"/>
			<HelpClasses:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
		</ResourceDictionary>
        

    </Window.Resources>

	<Window.DataContext>
		<Binding Path="Main" Source="{StaticResource Locator}"/>
	</Window.DataContext>

	<DockPanel x:Name="dockPanel1"  LastChildFill="true" Margin="0,0,0,0">
		<Border DockPanel.Dock="Bottom" Margin="0,0,0,0" HorizontalAlignment="Stretch" BorderThickness="1" CornerRadius="2" BorderBrush="Black">

			<WrapPanel Background="#FFE6E6E6" Margin="1" >

				<StackPanel Margin="1">
					<ComboBox x:Name="box" ItemsSource="{Binding NewNodes}" SelectedValue="{Binding SelectedNewNode}"  Height="24" VerticalAlignment="Top" Width="118" SelectedIndex="0"/>
					<Label Height="63"  Width="118"  Content="{Binding NewNode}"/>
				</StackPanel>
				<StackPanel Margin="1">
					<Label Content="Simulation Time" DockPanel.Dock="Top" Height="27" VerticalContentAlignment="Bottom"/>
					<StackPanel Orientation="Horizontal" Height="30" DockPanel.Dock ="Bottom">
						<xctk:IntegerUpDown MinWidth="55" Value="{Binding SimulationTime}" />
						<ComboBox SelectedIndex="0" SelectedValue="{Binding SimulationTimeUnit, Mode=OneWayToSource}">
							<ListBoxItem Content="Hours"/>
							<ListBoxItem Content="Weeks"/>
							<ListBoxItem Content="Years"/>


						</ComboBox>
						
					</StackPanel>
					<Label Content="Iterations"/>
					<xctk:IntegerUpDown MinHeight="30" Value="{Binding SimHandler.NrOfIterations}" />
				</StackPanel>
                <Button Width="100" Height="100" Margin="1" Click="Click_Load" Style="{DynamicResource ButtonBase}" >
					<adobeImport:OpenFileImage Margin="10,10,33,-10"></adobeImport:OpenFileImage>
				</Button>
                <Button Margin="1" Width="100" Height="100" Click="Click_Save"  Style="{DynamicResource ButtonBase}">
                    <adobeImport:Saveimage></adobeImport:Saveimage>
				</Button>
                <Button  Margin="1" Width="100" Height="100" Style="{DynamicResource ButtonBase}" Click="_newProduct_Click_1">
					<adobeImport:NewProductImage></adobeImport:NewProductImage>
				</Button>
                <Button  Margin="1" Width="100" Height="100"  Style="{DynamicResource ButtonBase}"  Command="{Binding RunSimulations}" >
				   <StackPanel>
                    <adobeImport:RunSimulationImage Margin="43,10,38,-10" RenderTransformOrigin="0.649,0.486" Visibility="{Binding SimHandler.IsRunning, Converter={StaticResource BooleanInvertToVisibilityConverter}}"/>
                        <adobeImport:StopSimulationImage Margin="43,10,38,-10" Visibility="{Binding SimHandler.IsRunning, Converter={StaticResource BooleanToVisibilityConverter}}" />
                    </StackPanel>
                </Button>
                <Button Margin="1" Width="100" Height="100" Style="{DynamicResource ButtonBase}" Visibility="{Binding ShowToResults, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" x:Name="ShowHideResults" Click="Retrive_Results" >
					<adobeImport:ResultImage Margin="10,10,-10,-10"  />
					
				</Button>
                <Button Margin="1" Width="100" Height="100" Style="{DynamicResource ButtonBase}"  Visibility="{Binding ShowToDesigner, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" Click="ToDesigner" >
					<adobeImport:DesignModeImage></adobeImport:DesignModeImage>
				</Button>
				<!--<Image Margin="1" RenderOptions.BitmapScalingMode="Fant" Height="100" Width="105" AllowDrop="True" Source="Resources/trash.png" Drop="Image_Drop_1"/>-->
				
				<adobeImport:DeleteImage  Height="100" Width="105" AllowDrop="True" Drop="Image_Drop_1"/>

				<Grid Margin="5,1,1,1" Width="400" Visibility="{Binding SimHandler.IsRunning, Converter={StaticResource BooleanToVisibilityConverter}}">
					<Label HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10"  Content="{Binding Path=SimHandler.TimeStatusString}"/>
					<ProgressBar   Value="{Binding SimHandler.Status}" Height="40"  />
				</Grid>
				
			</WrapPanel>
		</Border>
		<Border BorderThickness="1"  DockPanel.Dock="Right"  HorizontalAlignment="Right" CornerRadius="2"  Width="252" BorderBrush="Black" >
			<StackPanel Background="#FFDADADA" >
				<my:Products x:Name="Products"  MinHeight="89" VerticalAlignment="Bottom"/>
				<Label Content="Job Definition" Height="26" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="102"/>
				<!--<DataGrid DataContext="{Binding SelectedProduct}" ItemsSource="{Binding Nodes}"  Background="Transparent" AutoGenerateColumns="False">
				<DataGrid.Columns>
					<DataGridTemplateColumn MinWidth="18" Header="Remove">
						<DataGridTemplateColumn.CellTemplate>
							<DataTemplate>
								<Button Content="Delete"
									Command="{Binding Path=DeleteCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}
											  }"
									CommandParameter="{Binding}" />
							</DataTemplate>
						</DataGridTemplateColumn.CellTemplate>
					</DataGridTemplateColumn>
					<DataGridTextColumn  Header="Node" Binding="{Binding Key.ResourceModel.ProcessName, Mode=OneWay}"
									CanUserReorder="True" />

					<DataGridComboBoxColumn Header="Job" ItemsSource="{Binding Key.DeclaredJob}" DisplayMemberPath="Name"></DataGridComboBoxColumn>
				</DataGrid.Columns>
			</DataGrid>-->
				<ListBox ItemsSource="{Binding SelectedProduct.Nodes}" Background="Transparent" MinHeight="183"  VerticalAlignment="Top">
					<ListBox.ItemTemplate>
						<DataTemplate>
							<Grid >
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="97*"/>
									<ColumnDefinition Width="97*"/>
									<ColumnDefinition Width="100*"/>
									<ColumnDefinition Width="100*"/>
								</Grid.ColumnDefinitions>
								<Button Content="Delete" Grid.Column="0"
									Command="{Binding DataContext.SelectedProduct.DeleteCommand, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
									CommandParameter="{Binding}" />
								<Label  Grid.Column="1" Content="{Binding Key.ResourceModel.ProcessName}" />
								<ComboBox Grid.Column="2"  ItemsSource="{Binding Key.DeclaredJobs}" SelectedValue="{Binding Value}"/>
								<Button Grid.Column="3" Content="Up" Command="{Binding DataContext.SelectedProduct.MoveUpCommand, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
									CommandParameter="{Binding}" />
							</Grid>
						</DataTemplate>
					</ListBox.ItemTemplate>
				</ListBox>
				<StackPanel  Visibility="{Binding ShowResults, Converter={StaticResource BooleanToVisibilityConverter}}">
					<ComboBox Margin="0,0,0,0"  ItemsSource="{Binding TotalNodeConsumebles}" DisplayMemberPath="Key" SelectedValuePath="Key" SelectedValue="{Binding SelectedResultConsumable}"  VerticalAlignment="Top" />
					<!--<chartingToolkit:Chart Height="200"  Title="{Binding SelectedResultConsumable}"   >
						<chartingToolkit:Chart.LegendStyle>
							<Style TargetType="{x:Type Control}">
								<Setter Property="Width" Value="0" />
								<Setter Property="Height" Value="0" />
							</Style>
						</chartingToolkit:Chart.LegendStyle>
						<chartingToolkit:ColumnSeries ItemsSource="{Binding SelectedResultNodeConsumables}" 
							DependentValuePath="Value.Mean"
							IndependentValuePath="Key">
							<chartingToolkit:ColumnSeries.DependentRangeAxis>
								<chartingToolkit:LinearAxis Title="{Binding AxisUnit}" Orientation="Y" Minimum="0" />
							</chartingToolkit:ColumnSeries.DependentRangeAxis>
							<chartingToolkit:ColumnSeries.DataPointStyle>
								<Style TargetType="{x:Type chartingToolkit:ColumnDataPoint}">
									<Setter Property="Background" Value="#FF009E32"/>
									<Setter Property="Template">
										<Setter.Value>
											<ControlTemplate TargetType="{x:Type chartingToolkit:ColumnDataPoint}">
												<Grid>
													<Grid.ToolTip>

														<ToolTip Content="{TemplateBinding FormattedDependentValue}"/>
													</Grid.ToolTip>
													<Rectangle
														Fill="{TemplateBinding Background}"
														Stroke="Black"/>
												</Grid>
											</ControlTemplate>
										</Setter.Value>
									</Setter>
								</Style>
							</chartingToolkit:ColumnSeries.DataPointStyle>
						</chartingToolkit:ColumnSeries>
					</chartingToolkit:Chart>-->
					<chart1:SparrowChart MaxHeight="200" Margin="0,10,10,0" >
						<chart1:SparrowChart.XAxis> 
							<axis:CategoryXAxis   Visibility="Visible" />
						</chart1:SparrowChart.XAxis>

						<chart1:SparrowChart.YAxis >
							<axis:LinearYAxis Visibility="Visible" StringFormat="My Special Way"/>
						</chart1:SparrowChart.YAxis>

                        <series:BarErrorSeries  
											   PointsSource="{Binding SelectedResultNodeConsumables}" 
											   XPath="Key"
											   ErrorPath="Value.Std"
											   HighPath="Value.Mean" />
					</chart1:SparrowChart>
				</StackPanel>
			</StackPanel>
		</Border>

		<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
			<ItemsControl x:Name="add" ItemsSource="{Binding GridUIElement}">
				<ItemsControl.ItemsPanel>
					<ItemsPanelTemplate>
						<Grid DockPanel.Dock="Left" AllowDrop="True"  >
							<Grid.Background>
								<LinearGradientBrush EndPoint="1,1" MappingMode="RelativeToBoundingBox" StartPoint="0,0">
									<GradientStop Color="#FFD3CFCF"/>
									<GradientStop Color="White" Offset="1"/>
								</LinearGradientBrush>
							</Grid.Background>

						</Grid>
					</ItemsPanelTemplate>
				</ItemsControl.ItemsPanel>
			</ItemsControl>
		</ScrollViewer>

		<!--
		<ItemsControl ItemsSource="{Binding GridUIElement}">
			<ItemsControl.ItemsPanel>
				<ItemsPanelTemplate>
					<Grid DockPanel.Dock="Left"  />
				</ItemsPanelTemplate>
			</ItemsControl.ItemsPanel>
		 </ItemsControl>
		-->
		<!--<my:ModelNode HorizontalAlignment="Left" Margin="96,81,0,0" x:Name="modelNode1"
				VerticalAlignment="Top" Width="107" Height="63" Text="Production" MouseLeftButtonUp="NewNodeOnMouseLeftButtonUp"/>
			<my:ModelNode Height="63" Margin="359,81,0,0" x:Name="modelNode2"
				VerticalAlignment="Top" HorizontalAlignment="Left" Width="107" Text="Distribution"  MouseLeftButtonUp="NewNodeOnMouseLeftButtonUp"/>
			<my:ModelNode Height="63" HorizontalAlignment="Left" Margin="644,81,0,0" x:Name="modelNode3"
				VerticalAlignment="Top" Width="107" Text="Usage"  MouseLeftButtonUp="NewNodeOnMouseLeftButtonUp"/>
			<my:ModelNode Height="63" HorizontalAlignment="Left" Margin="900,81,0,0" x:Name="
		4"
				VerticalAlignment="Top" Width="107" Text="Recycle"  MouseLeftButtonUp="NewNodeOnMouseLeftButtonUp"/>-->



	</DockPanel>
</Window>